package io.github.libkodi.vertxauth.filter;

import java.util.regex.Pattern;

import io.github.libkodi.vertxauth.VertxWebAuth;
import io.github.libkodi.vertxauth.deal.Dealm;
import io.vertx.core.Future;
import io.vertx.ext.web.RoutingContext;

public class Filter {

	private String match;
	private Dealm filter;

	public Filter(String match, Dealm filter) {
		this.match = match;
		this.filter = filter;
	}
	
	public boolean isMatch(String path) {
		if (path == null) {
			path = "";
		}
		
		return Pattern.matches(match, path);
	}
	
	public Future<Void> dealm(VertxWebAuth auth, RoutingContext context) {
		return filter.dealm(auth, context);
	}

}
